﻿//获取浏览器参数
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

$(function () {
    var t = getQueryString("t");
    $('#rechargeAmount').focus();  //当前页面输入框选中

    $(document).on('keydown', function (e) {
        var oEvent = window.event;
        if (oEvent.keyCode == 85 && oEvent.ctrlKey) {
            oEvent.preventDefault();
            
            //跳转到注册页面
            parent.parent.other('newmember.html?t=1', '400px', '400px');
        }
        else {
            switch (e.keyCode) {
                case 27:   //Esc操作
                    e.preventDefault();
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                    if (t == 1) {
                        parent.$('#sku').focus();
                    }
                    else {
                        parent.window.location.reload();
                    }
                    break;
                case 13:    //回车
                    e.preventDefault();
                    var number = $.cookie('uid');
                    var rechargeAmount = $('#rechargeAmount').val(); //充值金额
                    recharge(number, rechargeAmount, "", "");
                    break;
            }
        }
    })
});

